package com.aeye.mbr.upms.server.controller;

import com.aeye.mbr.common.base.BaseController;
import com.aeye.mbr.common.listener.ApplicationContextListener;
import com.aeye.mbr.common.util.StringUtils;
import com.aeye.mbr.upms.dao.model.UpmsPermission;
import com.aeye.mbr.upms.dao.model.UpmsSystem;
import com.aeye.mbr.upms.dao.model.UpmsUser;
import com.aeye.mbr.upms.rpc.api.UpmsApiService;
import com.aeye.mbr.upms.rpc.api.UpmsSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 后台controller
 */
@Controller
@RequestMapping("/cache")
@Api(value = "缓存刷新", description = "缓存刷新")
public class CacheController extends BaseController {

	private static Logger _log = LoggerFactory.getLogger(CacheController.class);

	@ApiOperation(value = "刷新缓存")
	@RequestMapping(value = "/refresh")
	public 	@ResponseBody String refresh(HttpServletRequest request, @RequestParam String cacheName) {
		ApplicationContextListener.refreshCache(cacheName,""+System.currentTimeMillis());
		return "success";
	}

	@ApiOperation(value = "刷新缓存")
	@RequestMapping(value = "/toRefresh")
	public 	String toRefresh(HttpServletRequest request) {
		return "/cache/index.jsp";
	}
}